python-2.7

psutil.AccessDenied when using StanfordCoreNLP in Pycharm? [duplicate]

南楼画角 提交于 2021-01-29 05:20:27
问题 This question already has answers here : psutil.AccessDenied Error while trying to load StanfordCoreNLP (3 answers) Closed 6 months ago . # coding=utf-8 from stanfordcorenlp import StanfordCoreNLP nlp = StanfordCoreNLP(r'/Users/silas/stanford-corenlp/', lang='zh') sentence = '清华大学位于北京。' print nlp.word_tokenize(sentence) print nlp.pos_tag(sentence) print nlp.ner(sentence) print nlp.parse(sentence) print nlp.dependency_parse(sentence) nlp.close() I'm using Mac. Java, NLKT, and Stanforcorenlp

Shuffle list with empty (or None) elements [closed]

时光怂恿深爱的人放手 提交于 2021-01-29 04:52:22
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Improve this question I've got some list of lists and it values can be empty [] or NoneType lst = [[[]], [1, None], 2, [[], 3], 4] And I need to randomise them. To get [[1, None], 4, 2, [[], 3], [[]]] , for example. But if I use shuffle(lst) I've got an exception: TypeError:

TypeError: unsupported operand type(s) for /: 'str' and 'float'

孤者浪人 提交于 2021-01-29 04:48:13
问题 I am using Python 2 but I'm getting an error: TypeError: unsupported operand type(s) for /: 'str' and 'float' when the script runs to the last line. I don't understand which variable is still a string type. from sys import argv script, age, height=argv print 'you\'re %r old'%age weight=input('and i need your weight to calculate BMI, can you tell me:') print 'your BMI is %r'%weight/((float(height)/100)**2) 回答1: from sys import argv script, age, height=argv print 'you\'re %r old'%age weight

TypeError: unsupported operand type(s) for /: 'str' and 'float'

自闭症网瘾萝莉.ら 提交于 2021-01-29 04:40:45
问题 I am using Python 2 but I'm getting an error: TypeError: unsupported operand type(s) for /: 'str' and 'float' when the script runs to the last line. I don't understand which variable is still a string type. from sys import argv script, age, height=argv print 'you\'re %r old'%age weight=input('and i need your weight to calculate BMI, can you tell me:') print 'your BMI is %r'%weight/((float(height)/100)**2) 回答1: from sys import argv script, age, height=argv print 'you\'re %r old'%age weight

regex error : raise error, v # invalid expression

冷暖自知 提交于 2021-01-29 04:37:31
问题 I have a variable device='A/B/C/X1' that is commented out in another file. There can be multiple instances of the same device such as 'A/B/C/X1@1' , ..@2 and so on. All of these devices are commented out in another file with a prefix * . I want to remove the * but not affect similar devices like 'A/B/C/X**10**' . I tried using regex to simply substitute a pattern using the following line of code, but I'm getting an InvalidExpression error. line=re.sub('^*'+device+'@',device+'@',line) Please

regex error : raise error, v # invalid expression

巧了我就是萌 提交于 2021-01-29 04:36:24
问题 I have a variable device='A/B/C/X1' that is commented out in another file. There can be multiple instances of the same device such as 'A/B/C/X1@1' , ..@2 and so on. All of these devices are commented out in another file with a prefix * . I want to remove the * but not affect similar devices like 'A/B/C/X**10**' . I tried using regex to simply substitute a pattern using the following line of code, but I'm getting an InvalidExpression error. line=re.sub('^*'+device+'@',device+'@',line) Please

Shuffle list with empty (or None) elements [closed]

余生颓废 提交于 2021-01-29 04:30:20
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . Improve this question I've got some list of lists and it values can be empty [] or NoneType lst = [[[]], [1, None], 2, [[], 3], 4] And I need to randomise them. To get [[1, None], 4, 2, [[], 3], [[]]] , for example. But if I use shuffle(lst) I've got an exception: TypeError:

Scrape table with BeautifulSoup

一世执手 提交于 2021-01-29 04:20:49
问题 I have a table structure that looks like this : <tr><td> <td> <td bgcolor="#E6E6E6" valign="top" align="left">testtestestes</td> </tr> <tr nowrap="nowrap" valign="top" align="left"> <td nowrap="nowrap">8-K</td> <td class="small">Current report, items 1.01, 3.02, and 9.01 <br>Accession Number: 0001283140-16-000129  Act: 34  Size: 520 KB </td> <td nowrap="nowrap">2016-09-19<br>17:30:01</td> <td nowrap="nowrap">2016-09-19</td><td align="left" nowrap="nowrap"><a href="/cgi-bin/browse-edgar?action

Scrapy shell works but actual script returns 404 error

淺唱寂寞╮ 提交于 2021-01-29 04:17:54
问题 scrapy shell http://www.zara.com/us Returns a correct 200 code 2017-01-05 18:34:20 [scrapy.utils.log] INFO: Scrapy 1.3.0 started (bot: zara) 2017-01-05 18:34:20 [scrapy.utils.log] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'zara.spiders', 'ROBOTSTXT_OBEY': True, 'DUPEFILTER_CLASS': 'scrapy.dupefilters.BaseDupeFilter', 'SPIDER_MODULES': ['zara.spiders'], 'HTTPCACHE_ENABLED': True, 'BOT_NAME': 'zara', 'LOGSTATS_INTERVAL': 0, 'USER_AGENT': 'zara (+http://www.yourdomain.com)'} 2017-01-05 18

How can I interrupt a recvfrom() call in Python with keyboard?

久未见 提交于 2021-01-29 04:13:14
问题 I have a loop running in the main() function of my program that looks as follows while True: data, addr = sock.recvfrom(MAX_MESS_LEN) thread.start_new_thread(message_handler, (data, addr,)) I would like to introduce functionality that allows me to perhaps hit 'q' to break out of the loop and end the program. I'm not sure how to do this since the program waits on the recvfrom() call until receiving a message. Is there a way to implement an interrupt key or keyboard event catcher or something?