我正在尝试创建一个使用设置和Gui模块的用户系统,当gui模块请求使用pickle加载文件时,我不断收到属性错误.这是来自设置模块:
import pickle
import hashlib
class User(object):
def __init__(self, fname, lname, dob, gender):
self.firstname = fname
self.lastname = lname
self._dob = dob
self.gender = gender
self.type = 'General'
self._username = ''
self._hashkey = ''
def Report(self):
print("Full Name: {0} {1}\nDate of Birth: {2}\nGender: {3}\nAccess Level: {4}".format(self.firstname,self.lastname, self._dob, self.gender, self.type))
print(self._username)
def Genusername(self):
self._username = str(str(self._dob)[:2] + self.firstname[:2] + self.lastname[:2])
saveUsers(users)
def Genhashkey(self, password):
encoded = password.encode('utf-8','strict')
return hashlib.sha256(encoded).hexdigest()
def Verifypassword(self, password):
if self._hashkey == self.Genhashkey(password):
return True
else:
return False …Run Code Online (Sandbox Code Playgroud) 当我在命令提示符下运行以下命令时,我收到以下错误。
命令: C:\Users\ob>uiautomatorviewer
错误:
-Djava.ext.dirs=..\lib\x86_64;..\lib is not supported.
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Run Code Online (Sandbox Code Playgroud) 我在 Python 上构建了一个简单的 RSS 阅读器,但它不起作用。另外,我想获取每个帖子的精选图片源链接,但我没有找到方法。
它向我显示了错误:回溯(最近一次通话):文件“RSS_reader.py”,第 7 行,在 feed_title = feed['feed']['title'] 中
如果有其他一些 RSS 提要可以正常工作。所以我不明白为什么有些 RSS 提要有效,而另一些则无效
所以我想了解为什么代码不起作用,以及如何获取我附上代码的帖子的特色图片源链接,是在 Python 3.7 上编写的
import feedparser
import webbrowser
feed = feedparser.parse("https://finance.yahoo.com/rss/")
feed_title = feed['feed']['title']
feed_entries = feed.entries
for entry in feed.entries:
article_title = entry.title
article_link = entry.link
article_published_at = entry.published # Unicode string
article_published_at_parsed = entry.published_parsed # Time object
article_author = entry.author
content = entry.summary
article_tags = entry.tags
print ("{}[{}]".format(article_title, article_link))
print ("Published at {}".format(article_published_at))
print ("Published by {}".format(article_author))
print("Content {}".format(content))
print("catagory{}".format(article_tags))
Run Code Online (Sandbox Code Playgroud) 我在用scipy.optimize.minimize从函数中找到最佳值。这是最简单的示例,使用内置 Rosenbrock 函数:
>>> from scipy.optimize import minimize, rosen\n>>> x0 = [1.3, 0.7, 0.8, 1.9, 1.2]\n>>> # Minimize returns a scipy.optimize.OptimizeResult object...\n>>> res = minimize(rosen, x0, method='Nelder-Mead') \n>>> print res\n status: 0\n nfev: 243\n success: True\n fun: 6.6174817088845322e-05\n x: array([ 0.99910115, 0.99820923, 0.99646346, 0.99297555, 0.98600385])\n message: 'Optimization terminated successfully.'\n nit: 141\nRun Code Online (Sandbox Code Playgroud)\n\nx只是最终的最佳输入向量。\xe2\x80\x8b我可以从返回的结果中获取所有迭代的列表(即具有相应输入向量的目标函数)scipy.optimize.OptimizeResult?
我已经使用visual studio 2015开发了一个c ++项目.我的项目的输出是一个可执行文件,每个客户端必须有一个唯一的ID,并且该ID必须可以在代码中访问.一个简单的方法是在代码中定义一个常量变量,并为每个客户端更改其值并构建它多次,但我有一个Linux服务器,我不确定我是否可以构建它只是因为我使用了很多Winapi库.我在想,也许还有另一种方法可以改变输入或为输出添加一些常量值,就像操作可执行文件一样.例如:
#include <string>
#include <iostream>
#include <Windows.h>
const std::string ID = "some unique ID";
int main() {
std::cout << "Your ID: " << ID << std::endl;
getchar();
return(0);
}
Run Code Online (Sandbox Code Playgroud) 我在使用PyInstaller和时遇到问题statsmodels。当我运行可执行文件ImportError: No module named 'statsmodels.__init__.tools'时,出现错误消息,当我直接使用Python运行代码时,一切正常。
我已经尝试过这种解决方案。
我尝试添加statsmodels,statsmodels.__init__和statsmodels.__init__._version,但也无法正常工作。
我有一个 Windows Server 容器,我想通过 RDP 进入其桌面环境。看来微软已经在最近的Windows Server Core Containers中关闭了RDP。
我尝试跟进本教程。我可以使用远程桌面应用程序成功登录,但之后没有任何反应。好像没有桌面,或者可能还有其他问题。
我想知道是否有任何官方 Windows Server 映像可以访问其桌面 GUI,或者是否有其他方法可以添加此功能。
未处理的异常:Firebase.Database.FirebaseException:处理请求时发生异常。网址: https: //mylimo-b2029.firebaseio.com/users/.json请求数据:响应:发生 {"first_name":"dsadas"}
Mainpage.xaml.cs:
protected async override void OnAppearing()
{
base.OnAppearing();
var allUsers = await firebaseHelper.GetAllUsers();
lstPersons.ItemsSource = allUsers;
}
Run Code Online (Sandbox Code Playgroud)
Firebasehelper.cs:
public async Task<List<Users>> GetAllUsers()
{
return (await firebase
.Child("users")
.OnceAsync<Users>()).Select(item => new Users
{
//user_id = item.Object.user_id,
first_name = item.Object.first_name
}).ToList();
}
Run Code Online (Sandbox Code Playgroud) 我试图在我的类中创建一个方法来计算特定函数的完整运行。我想使用一个简单的装饰器。我找到了这个参考并重写了这个简单的脚本:
class myclass:
def __init__(self):
self.cnt = 0
def counter(function):
"""
this method counts the runtime of a function
"""
def wrapper(self, **args):
function(**args)
self.counter += 1
return wrapper
@myclass.counter
def somefunc():
print("hello from somefunc")
if __name__ == "__main__":
obj = myclass()
# or if comment @myclass.counter
# somefunc = myclass.counter(somefunc)
somefunc()
Run Code Online (Sandbox Code Playgroud)
当然,我得到:
TypeError: wrapper() missing 1 required positional argument: 'self'
Run Code Online (Sandbox Code Playgroud)
我尝试将计数器重写为类方法:
class myclass:
def __init__(self):
self.cnt = 0
def counter(self, function):
"""
this method counts the runtime …Run Code Online (Sandbox Code Playgroud) 我有一个看起来像这样的代码:
\n\n%%time\nimport time\ntime.sleep(3)\nRun Code Online (Sandbox Code Playgroud)\n\n当我在 jupyter 中执行此单元时,我得到以下输出:
\n\nCPU times: user 791 \xc2\xb5s, sys: 1.47 ms, total: 2.27 ms\nWall time: 3 s\nRun Code Online (Sandbox Code Playgroud)\n\n我的问题是,当我放置时,sleep(3)总时间不应该是 3 秒而不是 2.27 毫秒。
python ×6
c++ ×1
compilation ×1
docker ×1
feedparser ×1
firebase ×1
jupyter ×1
login ×1
minimization ×1
optimization ×1
pickle ×1
pyinstaller ×1
pyqt4 ×1
python-3.7 ×1
rss ×1
scipy ×1
statsmodels ×1
time ×1
xamarin ×1