Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Traceback (most recent call last):
- File "words.py", line 10, in <module>
- t = re.sub("'","",word)
- File "/usr/lib/python3.6/re.py", line 191, in sub
- return _compile(pattern, flags).sub(repl, string, count)
- TypeError: cannot use a string pattern on a bytes-like object
- #code
- import requests
- import re
- word_site = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-ty$
- response = requests.get(word_site)
- WORDS = response.content.splitlines()
- for word in WORDS:
- # print(word)
- t = re.sub("'","",word)
- print(t)
- :::
- before tried:
- import requests
- import re
- word_site = "http://svnweb.freebsd.org/csrg/share/dict/words?view=co&content-ty$
- response = requests.get(word_site)
- WORDS = response.content.splitlines()
- for word in WORDS:
- print(word)
- >>>> output
- ::: # I want to strip off the beginning b and the single quotes.
- b'zigging'
- b'zigzag'
- b'zigzagging'
- b'zilch'
- b'zillion'
- b'Zimmerman'
- b'zinc'
- b'zing'
- b'zinnia'
- b'Zion'
- b'zip'
- b'zircon'
- b'zirconium'
- b'zither'
- b'zloty'
- b'zodiac'
- b'zodiacal'
- b'Zoe'
- b'Zomba'
- b'zombie'
- b'zone'
- b'zoo'
- b'zoology'
- b'zoom'
- b'zooplankton'
- b'Zorn'
- b'Zoroaster'
- b'Zoroastrian'
- b'zounds'
- b"z's"
- b'zucchini'
- b'Zulu'
- b'Zurich'
- b'zygote'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement