私信  •  关注

Joran Beasley

Joran Beasley 最近创建的主题
Joran Beasley 最近回复了
3 年前
回复了 Joran Beasley 创建的主题 » python Pastebin API的问题:错误的API请求

尝试将其更改为api_dev_key?

Post = PostPastebinAPI({
    "api_dev_key": "<YOUR API KEY HERE>",
    "api_option": "paste",
    "api_paste_code": "Test"
})
3 年前
回复了 Joran Beasley 创建的主题 » 如何在python中将Json转换为表
import pandas
print(pandas.DataFrame(data))

我想也许你想做的。。。

5 年前
回复了 Joran Beasley 创建的主题 » 与python的串行通信

只需设置一个超时并读取,直到发生这种情况

import pyserial
connection = serial.Serial(
        'COM1',
        baudrate=9600,
        bytesize=8,
        patity='N',
        stopbits=1,
        timeout=1 # could probably be less
    )
# maybe .... are there some docs for whatever switch you are using?
connection.write("r source!\n")
# you might need connection.write(b"r source!")
print(connection.read(1000)) # try and read 1000 bytes or until timeout ocurres(1 sec)
# if you knew what the terminal character the device sends is you could just readuntil that character
6 年前
回复了 Joran Beasley 创建的主题 » 如何使用python打印姓名

而不是打印它们创建一个dict。。。只需输入大写并查找

d = {
  # A B C ...
  "G": "..######..\n..#.......\n..#..###..\n..#....#..\n..######..\n\n",
  "H": "..#....#..\n..#....#..\n..######..\n..#....#..\n..#....#..\n\n",
  "I": "..######..\n....##....\n....##....\n....##....\n..######..\n\n",
  "J": "..######..\n....##....\n....##....\n..#.##....\n..####....\n\n",
  "K": "..#...#...\n..#..#....\n..##......\n..#..#....\n..#...#...\n\n"
  # L M N
  # convert the rest of the print statements to dict entries
# print("..#.......\n..#.......\n..#.......\n..#.......\n..######..\n\n")
# print("..#....#..\n..##..##..\n..#.##.#..\n..#....#..\n..#....#..\n\n")

}
def print_word(word):
  for letter in word.upper():
     print(d[letter])

print_word("jIg")
6 年前
回复了 Joran Beasley 创建的主题 » 使用python编程语言调用rest api
import requests
from requests.auth import HTTPBasicAuth

requests.get("http://google.com:8070/api/v2/organizations",auth=HTTPBasicAuth('user', 'pass'))

你真的应该读一些文档,写一些代码…通过一些非常快速的谷歌搜索(即“python http身份验证请求”),这些事情变得非常明显。

http://docs.python-requests.org/en/master/user/authentication/

6 年前
回复了 Joran Beasley 创建的主题 » python:向实例添加属性,使其出现在类中

这个 setattr 方法

x = "temperature"
setattr(red,x,"HOT")

我想是你想要的

但也许你想要的是 __setattr__ __getattr__ 颜色类的方法

class color:
     attrs = {}
     def __getattr__(self,item):
         if item in self.attrs:
            return self.attrs[item]
         return ""
     def __setattr__(self,attr,value):
         self.attrs[attr] = value

c = color()
print(repr(c.hello))
c.hello = 5
print(repr(c.hello))
print(repr(c.temperature))
x = 'temperature'
setattr(c,x,"HOT")
print(repr(c.temperature))
6 年前
回复了 Joran Beasley 创建的主题 » 如何使用pycharm查看SQLite数据库中的哪些数据?[关闭]

5张图片中的一个故事,显然不算作文本,但实际上价值1000字。

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here