python-3.7

Are Python.requests safe?

不羁的心 提交于 2021-02-04 21:24:14
问题 I'm about to use Python.requests to get data from my own online api to my local pc. My api requires authentication which for now is done trough simply posting user/pass: params = {'user': 'username', 'pass':'password'} requests.post(url, params=params) Are this requests safe or is it going to allow a middle-man to capture that user/pass? P.S My api is using a letsencrypt ssl certificate. Python version 3.7.0 回答1: this has nothing to do with the python-requests package, but with the HTTP (and

What causes Python error 'bad escape \C'?

浪尽此生 提交于 2021-02-04 07:35:26
问题 I just wrote a function that will look at a text file and count all of the instances of True and False in the text file. Here is my file ATOM 43 CA LYS A 5 14.038 15.691 37.608 1.00 15.15 C True ATOM 52 CA CYS A 6 16.184 12.782 38.807 1.00 16.72 C True ATOM 58 CA GLU A 7 17.496 12.053 35.319 1.00 14.06 C False ATOM 67 CA VAL A 8 18.375 15.721 34.871 1.00 12.27 C True ATOM 74 CA PHE A 9 20.066 15.836 38.288 1.00 12.13 C False ATOM 85 CA GLN A 10 22.355 12.978 37.249 1.00 12.54 C False And here

How to hold a 'key down' in Pygame?

99封情书 提交于 2021-01-29 22:12:18
问题 I use Pygame 1.9.6 and Python 3.7.4. I want to hold down the space bar and it continuously does the same action over and over. I know how to have have the button get pressed with KEYDOWN . I looked at the question: How to efficiently hold a key in Pygame? for answers but can't understand the one answer: while not done: keys = key.get_pressed() if keys[K_DOWN]: print "DOWN" for e in event.get(): pass # proceed other events. # always call event.get() or event.poll() in the main loop I don't get

how to play gtts mp3 file in discord voice channel the user is in (discord.py)

可紊 提交于 2021-01-29 16:52:33
问题 Like the title I need to play a gtts file into a voice channel what is the easiest way to do this? I am using python 3.7. Here is my code so far: @client.command(name="repeat") async def repeat(context): import gtts, ffmpeg from discord.ext import commands # grab the user who sent the command user = context.message.author voice_channel = user.voice.voice_channel channel = None # only play music if user is in a voice channel if voice_channel != None: await ctx.send(f"What do you want to say,

TypeError: 'bool' object is not callable while creating custom thread pool

旧时模样 提交于 2021-01-29 13:59:29
问题 I want to create a custom thread pool for having more control over the code for future needs. So far I haven't been able to write something functional. I want the threads to work separately from the main interpreter process. I don't need multi-core advantage. Threads(Worker) should listen for a change in queue size and run execute on the passed job. I cannot make this code work. Does anybody see any solution to make this work? import queue from threading import Thread import time import

reading two files by comparing all lines of file 2 with each line of file 1

做~自己de王妃 提交于 2021-01-29 11:17:50
问题 I'm trying to read two files and comparing two columns with dates in them and if the dates are the same, then I want to compare two values corresponding to the dates. I want to read one line of file 1 with all the lines of file 2 and then the next line of line 1 with all the lines of file 2. However, when I try to compare the dates, my for loop that reads the two files only runs once. How do I make it so that I can compare file 1 and file 2 as i said earlier? with open('file1.txt') as f1:

How to efficiently store an int into bytes?

六月ゝ 毕业季﹏ 提交于 2021-01-29 11:08:04
问题 I am developing a program that uses the python 3.7 socket library to send and receive information, and I want it to be efficient network wise (doesn't need to be all that fast, I don't have enough time to build it in C) meaning if I want to send the number 1024, I should only need 2 bytes. In C, all that needs to be done is cast the int as a string, access the first 2 bytes and that is that (2 byte number to a 2 byte array/"string"). In Python, even when using the bytes structures, I always

Is the print() function in python considered a void function?

拈花ヽ惹草 提交于 2021-01-29 11:00:05
问题 As the title says, is the print() function in python a void function? I thought the print() function returns and prints to screen what is passed into it. Now that I think about it, it seems like it doesn't return anything and is indeed a void function. Can someone verify this for me please? Thanks in advance! I've tried the following: some_variable = print() print(some_variable) None 回答1: It does not return a value, which is the same as returning None. You won't find it explicitly in the

why is Django giving me a 404 error

人盡茶涼 提交于 2021-01-29 10:30:08
问题 I am currently trying to complete the Django 2.0 tutorial Poll application. I am using Django version 2.0.7 and Python 3.7.0. I have set up a virtual environment for this project. I am very new to Django so apologies if my terminology is incorrect. Basically, I cant get part 1 to work. I have tried numerous times to run it and I cant seem to figure out why it wont work. Before I create the Polls app the site runs correctly and I get the rocket ship, however after I create the app, update

P4Python does not check out the file in Perforce

人走茶凉 提交于 2021-01-29 10:23:28
问题 I have following piece of code. I'm trying to check out two files from Perforce and put them in a changelist. But run_add does not check the files out. The only thing I see in Perforce is a empty changelist with no files in it. """ Checks out files from workspace using P4""" files = ['analyse-location.cfg', 'CMakeLists.txt'] p4 = P4() # Connect and disconnect if (p4.connected()): p4.disconnect() p4.port = portp4 p4.user = usernameP4 p4.password = passwordP4 p4.client = clientP4 try: p4