python-3.x

Tweepy to sqlite3

亡梦爱人 提交于 2021-02-17 06:59:07
问题 I'm trying to use Twitter's Streaming API to save tweets to a database using sqlite3. The problem is my database comes back empty. I'm using DB Browser for SQLIte to check the schema and the table and columns are there but no values for any column. Any thoughts? #create sql table conn = sqlite3.connect('twitter_one5.db') c = conn.cursor() c.execute('''CREATE TABLE tweets (coordinates integer, place text)''') conn.commit() conn.close() # open connection conn = sqlite3.connect('twitter_one5.db'

How do i run a python program just by typing the script name on windows 10 cmd line?

戏子无情 提交于 2021-02-17 06:49:34
问题 How do i run a python program just by typing the script name on windows 10 cmd line? Also without having to change directory. I already added my scripts folder and python folder to the path. tried also tu run assoc py.=PythonScript ftype PythonScript=python.exe %1 %* Here's the program's content: #! python3 # mapIt.py - Launches a map in the browser using an address from the command line or clipboard import webbrowser, sys, pyperclip if len(sys.argv) > 1: address = ' '.join(sys.argv[1:]) else

How to build google cloud serverless function for processing unprocess data from firebase

邮差的信 提交于 2021-02-17 06:43:22
问题 I am having a problem while creating a serverless google cloud function I need to write a Google Cloud Function in Python to run this script that will process unprocessed firebase raw data I already deployed it on GCP but on triggering it is trowing: error request cannot handle I want to run the script serverless to avoid it from manually running every day Can anyone help me out with this def process_session(self, session, utc_offset=0): s = {} try: edfbyte, analysis = process_session(session

Fixing right alignment of string formatting

。_饼干妹妹 提交于 2021-02-17 06:42:14
问题 I'm trying to align the output of the list like shown: But it keeps coming out like this: My code for all of this is: subject_amount = int(input("\nHow many subject do you want to enrol? ")) class Subject: def __init__(self, subject_code, credit_point): self.subject_code = subject_code self.credit_point = credit_point subjects = [] for i in range(1, (subject_amount + 1)): subject_code = input("\nEnter subject " + str(i) + ": ") credit_point = int(input("Enter subject " + str(i) + " credit

how can I disable multiple instances of a python script?

拜拜、爱过 提交于 2021-02-17 06:41:06
问题 I made a python program and I want to disable the option to launch it multiple times in parallel. I searched the web and found that I need to do it with socket and ports, but I didn't find any example of how to do it(I know the steps, but I need to search every step on google and I am not so sure how to start). I also found that there might be libraries that can do that but to specific operating systems. My script only targets Windows 10, so I need to find a library that does that to Windows

Python - np.inf not larger than number

馋奶兔 提交于 2021-02-17 06:30:26
问题 Why np.inf > 1e999 returns False? I'm using Python 3.7 回答1: The notation 1e999 results in a float -- and this float is larger than the maximum possible value. So 1e999 becomes inf . A quick test in Ipython: In [11]: 1e999 == np.inf Out[11]: True 来源: https://stackoverflow.com/questions/63585238/python-np-inf-not-larger-than-number

Spyder Console - Error ocurred while starting the Kernel

那年仲夏 提交于 2021-02-17 06:23:05
问题 Spyder console is showing an error msg: An error ocurred while starting the kernel Traceback (most recent call last): File "C:\Users\ABCD\Anaconda3\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "C:\Users\ABCD\Anaconda3\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\ABCD\Anaconda3\lib\site‑packages\spyder_kernels\console\__main__.py", line 11, in start.main() File "C:\Users\ABCD\Anaconda3\lib\site‑packages\spyder_kernels\console\start

How to loop through columns of a list?

喜夏-厌秋 提交于 2021-02-17 06:19:25
问题 I am trying to loop through a list of lists. I want to find the min and max of the columns in the list. This is the list: ['Afghanistan', 2.66171813, 7.460143566, 0.490880072, 52.33952713, 0.427010864, -0.106340349, 0.261178523] ['Albania', 4.639548302, 9.373718262, 0.637698293, 69.05165863, 0.74961102, -0.035140377, 0.457737535] ['Algeria', 5.248912334, 9.540244102, 0.806753874, 65.69918823, 0.436670482, -0.194670126, 0] ['Argentina', 6.039330006, 9.843519211, 0.906699121, 67.53870392, 0

Python: Error:TypeError: findall() missing 1 required positional argument: 'string'

穿精又带淫゛_ 提交于 2021-02-17 06:11:23
问题 I am trying to scrub a text document with specific parameters. Have tried different iterations of the x=... line but the program isn't able to read the all line. import re #import csv text = open(r'C:\Users\Vincent\Documents\python\theSortingHat\100000DirtyNames.txt') #open text file for line in text: #iterate through every line #return list of names in that line x = re.findall ('^([a-zA-Z]-?$') #if an actual name is found if x != 0: print(x) I receive: Error:TypeError: findall() missing 1

Python: Error:TypeError: findall() missing 1 required positional argument: 'string'

家住魔仙堡 提交于 2021-02-17 06:10:59
问题 I am trying to scrub a text document with specific parameters. Have tried different iterations of the x=... line but the program isn't able to read the all line. import re #import csv text = open(r'C:\Users\Vincent\Documents\python\theSortingHat\100000DirtyNames.txt') #open text file for line in text: #iterate through every line #return list of names in that line x = re.findall ('^([a-zA-Z]-?$') #if an actual name is found if x != 0: print(x) I receive: Error:TypeError: findall() missing 1