我想str在调试器中查看 的子类的类属性。
请参阅图片 - 我想要在旁边有下拉箭头a(这是一个POSString对象)。换句话说,在 Pycharm 调试器中,我希望能够选择双击并查看带有 value 的a属性,就像对象一样。bar"HELLO"foo
这在 PyCharm 中可能吗?如果可以,如何实现?
两个类:
class Foo:
bar = "HELLO"
class POSString(str):
bar = "HELLO"
def __init__(self, pos="", *args, **kwargs):
super().__init__(*args, **kwargs)
self.pos = pos
def __hash__(self):
return hash((str(self), self.pos))
def __eq__(self, other):
return super().__eq__(other) and self.pos == other.pos
Run Code Online (Sandbox Code Playgroud)
以及我如何创建我的两个对象:
foo = Foo()
a = POSString("banana")
Run Code Online (Sandbox Code Playgroud)
我正在使用Python 3.7.1。
PyCharm:
PyCharm 2018.2.5 (Professional Edition)
Build #PY-182.5107.22, built on November 13, 2018
JRE: …Run Code Online (Sandbox Code Playgroud) 如果我输入命令“python manage.py runserver” ,我希望 url ( http://127.0.0.1:8000 ) 自动打开浏览器(无需单击)。
我尝试在没有鼠标的情况下使用浏览器运行http://127.0.0.1:8000/ 。所以我尝试了所有能找到的快捷方式,但找不到它们。
python manage.py runserver
(venv) seongyoonhuh@seongyoonhuh:/media/seongyoonhuh/usb16g/20190619/basic$ python manage.py runserver
Performing system checks...
System check identified no issues (0 silenced).
June 19, 2019 - 17:39:37
Django version 2.2.2, using settings 'config.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Gitlab API 来解决 Python 问题。
以下 curl 请求有效(经过测试和确认):
curl --request POST --header "PRIVATE-TOKEN: <my token>" https://gitlab.com/api/v3/projects/<my project id>/issues?title=Issues%20with%20auth&labels=bug
Run Code Online (Sandbox Code Playgroud)
我的 Python 代码:
import requests
r = requests.post("https://gitlab.com/api/v3/projects/2674887/issues", data={
"title":issueform.instance.title,
"description":issueform.instance.description
},
headers={"PRIVATE_TOKEN":"<token>"})
print(r.status_code, r.reason)
Run Code Online (Sandbox Code Playgroud)
我得到:401 未经授权
我在 POST 请求中做错了什么,或者这是 GitLab 拒绝这样做的问题吗?
API 的相关部分:http : //docs.gitlab.com/ee/api/issues.html#new-issue
编辑:
忘了提,忽略这些issueform.instance东西,它们只是字符串(它是一个 Django 项目,我省略了表单的东西,因为它不应该是相关的)
我正在使用bootstrap-select。
select如果我在使用 的搜索菜单中找不到新选项data-live-search="true",因为它还不存在,我该如何添加新选项?
我正在努力根据客户的回答获得最低值。
$client_answer = 28;
$array = array(10,20,30,40,50);
Run Code Online (Sandbox Code Playgroud)
应该给出的答案是:20
所以每个答案都应该四舍五入到较低的数字。
其他例子:
$client_answer = 37;
$array = array(10,20,30,40,50);
Run Code Online (Sandbox Code Playgroud)
答案应该是 30。
$client_answer = 14;
$array = array(10,20,30,40,50);
Run Code Online (Sandbox Code Playgroud)
答案应该是10。
$client_answer = 45;
$array = array(10,20,30,40,50);
Run Code Online (Sandbox Code Playgroud)
答案应该是40。
是否有我可以使用的 php 函数?
如果不是,这如何实现?
我尝试在 amcharts 中实现一个带有子类别的聚集条形图(我的 x 轴上有两个级别)。我找不到办法做到这一点。
有谁知道怎么做?