Typeerror: Expected String or Buffer

TypeError: expected string or buffer

Change:

text= text1.readlines()

to:

text = text1.read()

Explanation:

re.subn(pattern, repl, string, count=0, flags=0)

You are passing a list for string here.

TypeError: expected string or buffer in Python

Try printing the href values.

for link in soup.findAll('a'):
print(link.get('href'))
result = re.sub(r"http\S+", "", link.get('href'))

You'll see there is a None value that comes up after extracting few links.

You can fix this by giving a if condition inside the loop

for link in soup.findAll('a'):
print(link.get('href'))
if link.get('href')==None:
continue
result = re.sub(r"http\S+", "", link.get('href'))

Pyglet - TypeError: expected string or buffer

It seems this bug was introduced with this recent change. You should definitely raise it on pyglet github issue tracker.

Meanwhile, try installing the version prior to 1.4.8. (I though suspect this may just lead to crashing on failed sync as opposed to trying to warn you and then crashing :)).

Why do I get expected string or buffer, when I am working with strings?

For starters, you may want to change _string_copy = p.sub(_string,n2w) to _string_copy = p.sub(n2w,_string). In addition, it would help if you can also provide a sample of your JSON file. Then, though not sure what you want, you might consider changing extractedData = np.array(questions,articleTitles,articleTexts,answers) to extractedData = np.array([questions,articleTitles,articleTexts,answers])

Python TypeError: expected string or buffer with re and csv

It's because your row variable is a list, not a string - and Python is warning you that it expects a string. try something like this:

import csv
import re

with open('names.csv') as namescsv:
namereader = csv.reader(namescsv)
for row in namereader:
for cell in row:
cell = re.sub(r'[^\w=]', '',cell)
print cell

TypeError: expected string or buffer python re.search

I don't think you need regex here at all.

According to the PyNetgear docs, get_attached_devices returns a list of named tuples. You will need to iterate through the list and print the mac value:

for item in devices:
print(item.mac)


Related Topics



Leave a reply



Submit