Python Windows基础_Yew1168的博客-程序员秘密_python windows

技术标签: windows  Python  

https://docs.python.org/3/faq/windows.html#how-do-i-run-a-python-program-under-windows

1.cmd模式下Ctrl-Z退出Python;或者exit();

2. 默认关联py文件,双击自动运行On Windows, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file type an open command that runs the interpreter (D:\Program Files\Python\python.exe "%1" %*). This is enough to make scripts executable from the command prompt as ‘foo.py’. If you’d rather be able to execute the script by simple typing ‘foo’ with no extension you need to add .py to the PATHEXT environment variable.

3.创建exe See cx_Freeze for a distutils extension that allows you to create console and GUI executables from Python code.py2exe, the most popular extension for building Python 2.x-based executables, does not yet support Python 3 but a version that does is in development.

4.pyd dll : .pyd files are dll’s, but there are a few differences. If you have a DLL named foo.pyd, then it must have a function PyInit_foo(). You can then write Python “import foo”, and Python will search for foo.pyd (as well as foo.py, foo.pyc) and if it finds it, will attempt to call PyInit_foo() to initialize it. You do not link your .exe with foo.lib, as that would cause Windows to require the DLL to be present.

Note that the search path for foo.pyd is PYTHONPATH, not the same as the path that Windows uses to search for foo.dll. Also, foo.pyd need not be present to run your program, whereas if you linked your program with a dll, the dll is required. Of course, foo.pyd is required if you want to say import foo. In a DLL, linkage is declared in the source code with __declspec(dllexport). In a .pyd, linkage is defined in a list of available functions.

5.How can I embed Python into a Windows application?

Do _not_ build Python into your .exe file directly. On Windows, Python must be a DLL to handle importing modules that are themselves DLL’s. (This is the first key undocumented fact.) Instead, link to pythonNN.dll; it is typically installed in C:\Windows\SystemNN is the Python version, a number such as “33” for Python 3.3.

You can link to Python in two different ways. Load-time linking means linking against pythonNN.lib, while run-time linking means linking against pythonNN.dll. (General note: pythonNN.lib is the so-called “import lib” corresponding to pythonNN.dll. It merely defines symbols for the linker.)

Run-time linking greatly simplifies link options; everything happens at run time. Your code must load pythonNN.dll using the Windows LoadLibraryEx() routine. The code must also use access routines and data in pythonNN.dll (that is, Python’s C API’s) using pointers obtained by the Windows GetProcAddress()routine. Macros can make using these pointers transparent to any C code that calls routines in Python’s C API.

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/yaoyutian/article/details/83904753

智能推荐

Longest Continuous Increasing Subsequence_weixin_30799995的博客-程序员秘密

    这道题为简单题  题目:      思路:    设置三个变量,max_long 存储总的最大长度,l代表该值目前的最大长度,num主要用来比较列表的前后大小。如果i大于num那么l就一直加1.否则l就和max_long比较大小,l变为1,num更新为i值  代码: 1 class Solution: 2 def findLengthOfLCI...

Android studio中的一些小技巧_dandelionsnow的博客-程序员秘密

一,在Android studio中使用HttpClient,需要在在Android studio中使用HttpClient,需要在build.gradle中加入:android {useLibrary 'org.apache.http.legacy'}二,如何将ProgressBar变为水平进度条?在布局中加入: style="?android:attr/

学习:CAS算法的理解和ABA问题的解决_cas算法和abc问题_嗑瓜子儿溜茶水儿的博客-程序员秘密

学习了CAS算法的原理,以及ABA问题的解决。记录个人理解。CAS 算法:全称 Compare And Swap ,比较交换算法。举个例子说明算法的思路:有一个变量 int a = 0;在多线程条件下,每个线程使变量 a 进行自增操作有一个线程 线程1线程1 对 a 的操作如下: 1. 获取 a 当前的值,并保存为 a1 2. 计算 a1 + 1 的结果 3. 检查 a 当前的值,并与 a1 进行比较如果比较结果相同,则将计算后的值赋给 a,完成自增;如果比较结果不相同,则将重复

Go语言中常见的几种反模式[译]_Tony Bai的博客-程序员秘密

本文翻译自Saif Sadiq的文章《Common anti-patterns in Go》[1]。众所周知,编码是一门艺术,就像每个拥有精湛艺术并为之感到骄傲的工匠一样,我们作为开发人员...

获取input的值或文件_如何获取input上传文件的值_qq_43919485的博客-程序员秘密

1、vue获取input的值,方法一:方法二:2、vue获取文件3、用jquery获取input中的文件用 $("#ff")[0].files[0]4、用jquery获取input的值,通过id、class方法一:用KaTeX parse error: Expected 'EOF', got '#' at position 3: ("#̲ss").val()用(".ss")....

nutz-sqltpl 1.3.RELEASE 发布,“解决java拼接sql”_weixin_34378045的博客-程序员秘密

开发四年只会写业务代码,分布式高并发都不会还做程序员? >>> 简单介绍1、使用 x...

随便推点

多态简单的例子_多态的例子_一份耕耘一份收获。的博客-程序员秘密

class Animal{ private String name; Animal(String name){ this.name=name; } public void enjoy(){ System.out.println("动物的叫声....."); }}class Cat extends Animal{ private String eyeColor; Cat...

【QML】qml动画机制总结_qml 动画_iriczhao的博客-程序员秘密

一、引言使用Qml进行项目开发时,往往需要控制一个显示控件的x,y,z三轴的坐标值,旋转,缩放,变化等。这些效果可以使用QML的动画类型进行实现。本文总结qml的动画机制,重点记录qml动画机制的主要QML类型,以及一些属性使用方法。二、qml动画机制的主要类型如上图所示,qml动画的根为Animation,在实际项目开发中,使用比较多的还是ColorAnimation、 NumberAnimation和RotationAnimation三个属性动画。三、Animation【属性】1、alw

duplicated with element declared at AndroidManifest.xml:11:9-20:20_林冬136的博客-程序员秘密

问题duplicated with element declared at AndroidManifest.xml:11:9-20:20Execution failed for task ':app:processDebugManifest'Manifest merger failed with multiple errors,see logs原因         An

sftp文件下载工具类_sftp下载文件工具类_小明同学——的博客-程序员秘密

sftp文件下载工具类事例:支付宝下载对账单import java.io.File;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.util.*;imp...

linux mint安装deb文件及出现的问题_linuxmint .deb_凌-志的博客-程序员秘密

毕竟mint的祖宗是ubuntu,除了命令安装某些文件外,也有大部分是只能通过直接浏览器下载,要是tar.gz文件也就无可厚非,而当时deb时第一次安装可能就有点呛了吧...deb文件是ubuntu系统下的,当然mint也是能使用的,只是取要驱动才能干活。我的第一次给了chrome浏览器,当时从官网下载后使用 sudo gdebi google-chrome-stable_current_

vue项目中批量打印二维码_天道酬勤dl的博客-程序员秘密

综合了两个文章实现。首先使用qrcode实现生成。然后window.open和window.print打印一、生成二维码(原文链接:https://www.cnblogs.com/feijiediyimei/p/11136607.html) 最近项目有个需求,需要将一个连接生成二维码展示出来,然后在网上找到了QRCode这个插件,这里大致记录下它的使用方法介绍: QRCode.js 是一个用于生成二维码的 JavaScript 库。主要是通过获取 DOM 的标签,再通过 HTML5