python-3.x

Python telegraph api. I can't understand how send image to telegraph via Python lib

China☆狼群 提交于 2021-02-11 14:12:24
问题 I'm trying to upload a photo from my hard drive to the telegraph. In the documentation it says to use the upload_file(): telegraph.upload.upload_file(f) Upload file to Telegra.ph’s servers. Returns a list of links. Allowed only .jpg, .jpeg, .png, .gif and .mp4 files. Parameters: f (file, str or list) – filename or file-like object. But I don't understand what "f (file, str or list) – filename or file-like object" means. That is, what do I need to do with the photo so that it can be passed to

Counting repeated STR in DNA PSET6 CS50

試著忘記壹切 提交于 2021-02-11 14:12:02
问题 Currently working on CS50. I tried to count STR in file DNA Sequences but it always overcount. I mean, for example: how much 'AGATC' in file DNA repeat consecutively. This code is only try to find out how to count those repeated DNA accurately. import csv import re from sys import argv, exit def main(): if len(argv) != 3: print("Usage: python dna.py data.csv sequence.txt") exit(1) with open(argv[1]) as csv_file, open(argv[2]) as dna_file: reader = csv.reader(csv_file) #for row in reader: #

Getting user input within tqdm loops

自古美人都是妖i 提交于 2021-02-11 14:11:04
问题 I'm writing a script where a user has to provide input for each element of a large list. I'm trying to use tqdm to provide a progress bar for the user, but I can't find a good way to get input within the tqdm loop without breaking the output. I'm aware of tqdm.write() for writing to the terminal during a tqdm loop, but is there a way of getting input? For an example of what I'm trying to do, consider the code below: from tqdm import tqdm import sys from time import sleep def do_stuff(x):

PyQt5: How to Re-Dock back a floated QDockWidget via a QPushButton?

此生再无相见时 提交于 2021-02-11 14:10:51
问题 I which to bring back to initial state an Undocked or floated QDockWidget with a QPushButton. from PyQt5 import QtCore, QtGui, QtWidgets class Mainwindow(object): def setupUi(self, window): window.setObjectName("window") window.resize(309, 148) self.centralwidget = QtWidgets.QWidget(window) self.centralwidget.setObjectName("centralwidget") self.Undock_btn = QtWidgets.QPushButton(self.centralwidget) self.Undock_btn.setGeometry(QtCore.QRect(4, 4, 100, 22)) self.Undock_btn.setStyleSheet(

Add ?q=search+term in django url

≡放荡痞女 提交于 2021-02-11 14:04:17
问题 I want to integrate elastic search with django but first I need to get a nice parameter in url http://127.0.0.1:8000/search?q=search+term urls.py (of the view) urlpatterns = [ path('?q=', SearchIndexView.as_view(), name="search-index"), ] urls.py (of the app) urlpatterns = [ path('admin/', admin.site.urls), path('', include('home.urls')), path('u/', include('user.urls')), path('search', include('search.urls')), ] That is what I have so far but I cant figure out how to make it work. I want to

Django - Messages functionality not working in Class based view

十年热恋 提交于 2021-02-11 14:02:43
问题 Unable to display messages in class based view. In another app's views.py, it is working fine where I used function based view. views.py: class PostDeleteView(LoginRequiredMixin, UserPassesTestMixin, SuccessMessageMixin, DeleteView): model = Post success_url = '/user-profile/' success_message = "Your post has been deleted sucessfully!" def test_func(self): post = self.get_object() if self.request.user == post.author: return True return False urls.py: path('user-profile/', user_views.user

how to send incoming messages from socket client to GUI (pyqt5)

喜夏-厌秋 提交于 2021-02-11 13:59:56
问题 I am trying to make a chat application using socket library. I have three files server.py , client.py and gui.py listening process for client and server are provided by infinite loops. because of that server.py runs in another terminal window. but client and gui are running in one terminal window. the problem is when I call functions containing infinite loop it stuck there and the rest of code won't run. I even tried using multiprocessing , threading.Thread , threading.Timer , QThread and

How can I create an object of a child class inside parent class?

三世轮回 提交于 2021-02-11 13:59:56
问题 I have this code in test.py: class Parent(object): def __init__(self): self.myprop1 = "some" self.myprop2 = "thing" def duplicate(self): copy = Parent() copy.myprop1 = self.myprop1 copy.myprop2 = self.myprop2 return copy And this other in test2.py: from test import Parent class Child(Parent): def __str__(self): return "{}, {}".format(self.myprop1, self.myprop2) obj1 = Child() obj2 = obj1.duplicate() obj2.myprop1 = "another" obj2.myprop2 = "stuff" # Accessing properties print("obj1, ", obj1

cl.exe installed but not found

柔情痞子 提交于 2021-02-11 13:55:04
问题 I've looked at the other questions on this, all say install visual studio with c++, I have done this - 2017 version. I'm trying to build pypoisson in python3 which requires the c++ complier, I get this error: cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\garyn\PycharmProjects\pointcloudprocessor\venv\lib\site-packages\numpy\core\include -IC:\Users\garyn\PycharmProjects\pointcloudprocessor\venv\include "-IC:\Pr ogram Files\Python\Python37\include" "-IC:\Program Files\Python\Python37

Python +Selenium can't find element to send key

被刻印的时光 ゝ 提交于 2021-02-11 13:54:40
问题 I already deal with it for many days having no idea how to solve it... That is the element I want to get by selenium <input name="QUICKSEARCH_STRING" id="QUICKSEARCH_STRING" onfocus="setTimeout('focusSearchElem()', 100);" type="text" value=""> They all pop out the warning like this one ===> Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="QUICKSEARCH_STRING"]"} (Session info: chrome=79.0.3945.88) It is my code: import selenium.webdriver from