www.91084.com

GVKun编程网logo

Python Windows`msvcrt.getch()`仅检测到每3次按键?(检测到python编程环境中存在多个版本)

11

本文将介绍PythonWindows`msvcrt.getch的详细情况,特别是关于`仅检测到每3次按键?的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一

本文将介绍Python Windows`msvcrt.getch的详细情况,特别是关于`仅检测到每3次按键?的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于getpass.getpass([prompt])引发错误,因为“ win_getpass msvcrt.putwch(c)TypeError:putwch()参数必须是Unicode字符,而不是模块”、Getting Django Started on Windows 7 with Python 3 and MySQL_MySQL、Java中的getPath(),getAbsolutePath()和getCanonicalPath()有什么区别?、msvcrt.kbhit()始终返回false无法检测到转义键的知识。

本文目录一览:

Python Windows`msvcrt.getch()`仅检测到每3次按键?(检测到python编程环境中存在多个版本)

Python Windows`msvcrt.getch()`仅检测到每3次按键?(检测到python编程环境中存在多个版本)

我的代码如下:

import msvcrtwhile True:    if msvcrt.getch() == ''q'':           print "Q was pressed"    elif msvcrt.getch() == ''x'':           sys.exit()    else:       print "Key Pressed:" + str(msvcrt.getch()

这段代码就是基于这个问题;我用它来熟悉自己getch

我已经注意到,按3键3次才能输出一次文本。为什么是这样?我正在尝试将其用作事件循环,这太滞后了…

即使我键入3个 不同的 键,它也只输出第3个按键。

我怎样才能迫使它更快?有没有更好的方法来实现我要实现的目标?

谢谢!

逃避

答案1

小编典典

您在循环中调用了该函数3次。尝试仅这样调用一次:

import msvcrtwhile True:    pressedKey = msvcrt.getch()    if pressedKey == ''q'':           print "Q was pressed"    elif pressedKey == ''x'':           sys.exit()    else:       print "Key Pressed:" + str(pressedKey)

getpass.getpass([prompt])引发错误,因为“ win_getpass msvcrt.putwch(c)TypeError:putwch()参数必须是Unicode字符,而不是模块”

getpass.getpass([prompt])引发错误,因为“ win_getpass msvcrt.putwch(c)TypeError:putwch()参数必须是Unicode字符,而不是模块”

如何解决getpass.getpass([prompt])引发错误,因为“ win_getpass msvcrt.putwch(c)TypeError:putwch()参数必须是Unicode字符,而不是模块”?

导入getpass

导入提示作为提示 密码= getpass.getpass([提示]) 打印(密码)

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

Getting Django Started on Windows 7 with Python 3 and MySQL_MySQL

Getting Django Started on Windows 7 with Python 3 and MySQL_MySQL

pythonDjango

bitsCN.com 07.03.2014|6 views|

Related MicroZone Resources

clustrix whitepapers

What We Offer: Clustrix Features

INFOGRAPHIC: The Future of the Database

Proven in Production: Clustrix Case Studies

Like this piece? Share it with your friends:

立即学习“Python免费学习笔记(深入)”;

|More

Django is a Python web framework library and it works on both Python 2 or 3. I will show you how to get python 3 set up in Cygwin environment.

If you''re on a Windows OS, the best experience I have when working with Django on Windows is to use Cygwin, a Unix emulator shell that runs on Windows. The pip and django commands would automatically setup in Cygwin''s PATH after installed. The default python package on Cygwin is only 2.7 though, so you have to search for "python3" package to get the latest python version. And you can have both versions installed without problem, but the executable are named "python" and "python3" respectively.

1. Install Cygwin python3 package. Verify "python3 -V" is working.

2. Install "pip" by downloading this "get-pip.py" file fromhttp://pip.readthedocs.org/en/latest/installing.htmland then run "python3 get-pip.py". Verify "pip3 --version" is working.

(NOTE: If you are running Windows 7, you might run into this issue:https://github.com/pypa/pip/issues/1448where pip exit without a warning. In this case the workaround is install Cygwin "binutils" and "libuuid-devel"packages, and that fixed the problem for me.)

3. Install "django" by running "pip3 install django"

4. Finally install the MySQL driver with "pip3 install mysql-connector-python --allow-external mysql-connector-python" command.

Now to get a django project started, try these:

django-admin.py startproject myapp
登录后复制

The "django-admin.py" script should automatically in your PATH. and this create a new project with initial settings. To switch default database from SQLite3 to MySQL, change the "myapp/settings.py" with the following:

DATABASES = {	''default'': {		''NAME'': ''mydb'',		''ENGINE'': ''mysql.connector.django'',		''USER'': ''root'',		''PASSWORD'': ''secret'',	}}
登录后复制

Now I assume you have MySQL 5.6+ installed on your Windows already. Change the root password to match yours or using different DB user. You can now have django app setup the initial database schema tables for this specif myapp with this commad:

cd myapp
登录后复制
python3 manage.py syncdb
登录后复制

Follow the prompt and setup your admin user. Now you can start django web app:

python3 manage.py runserver
登录后复制

Open browser to http://localhost:8000/admin. Now try to login and enjoy!

  • https://www.python.org
  • http://cygwin.com
  • http://dev.mysql.com
  • https://docs.djangoproject.com

Published at DZone with permission ofZemian Deng, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Tags:
  • cygwin
  • django
  • Tips and Tricks
  • Python
  • Tools & Methods
bitsCN.com

Java中的getPath(),getAbsolutePath()和getCanonicalPath()有什么区别?

Java中的getPath(),getAbsolutePath()和getCanonicalPath()有什么区别?

什么之间的区别getPath()getAbsolutePath()以及getCanonicalPath()在Java中?

以及何时使用每一个?

msvcrt.kbhit()始终返回false无法检测到转义键

msvcrt.kbhit()始终返回false无法检测到转义键

尝试:如果msvcrt.getch()== b'\ x1b'

例如:

import msvcrt
while True:
    if msvcrt.kbhit():
        key_stroke = msvcrt.getch()
        if key_stroke==b'\x1b':
            print ("Esc key pressed")
        else:
            print (str(key_stroke).split("'")[1],"key pressed")

今天关于Python Windows`msvcrt.getch`仅检测到每3次按键?的介绍到此结束,谢谢您的阅读,有关getpass.getpass([prompt])引发错误,因为“ win_getpass msvcrt.putwch(c)TypeError:putwch()参数必须是Unicode字符,而不是模块”、Getting Django Started on Windows 7 with Python 3 and MySQL_MySQL、Java中的getPath(),getAbsolutePath()和getCanonicalPath()有什么区别?、msvcrt.kbhit()始终返回false无法检测到转义键等更多相关知识的信息可以在本站进行查询。

本文标签: