我可以在同一台机器上使用简单的套接字通信
服务器:
import socket
s = socket.socket()
host = socket.socket()
port = 8000
s.bind((host,port))
s.listen(5)
while true:
c,addr = s.accept()
print 'got connection from', addr
c.send('thank you for connecting')
c.close()
Run Code Online (Sandbox Code Playgroud)
客户:
import socket
s = socket.socket()
host=socket.gethostname()
port = 8000
s.connect((host,port))
print s.recv(1024)
Run Code Online (Sandbox Code Playgroud)
我的笔记本电脑和我工作的私人服务器之间需要进行哪些更改才能进行通信?我从我的搜索中发现,portforwarding是最好的方法,但没有找到任何解释或教程如何去做.
谢谢
我正在使用这两个程序在我的两台计算机之间进行通信,其中一台是我正在进行的,而且我没有返回任何一方.它只运行而不发送任何东西
客户
import sys
from socket import socket, AF_INET, SOCK_DGRAM
SERVER_IP = '127.0.0.1'
PORT_NUMBER = 5000
SIZE = 1024
print ("Test client sending packets to IP {0}, via port {1}\n".format(SERVER_IP, PORT_NUMBER))
mySocket = socket( AF_INET, SOCK_DGRAM )
while True:
mySocket.sendto('cool',(SERVER_IP,PORT_NUMBER))
sys.exit()
Run Code Online (Sandbox Code Playgroud)
服务器
from socket import socket, gethostbyname, AF_INET, SOCK_DGRAM
import sys
PORT_NUMBER = 5000
SIZE = 1024
hostName = gethostbyname( '0.0.0.0' )
mySocket = socket( AF_INET, SOCK_DGRAM )
mySocket.bind( (hostName, PORT_NUMBER) )
print ("Test server listening on port {0}\n".format(PORT_NUMBER))
while …Run Code Online (Sandbox Code Playgroud) 我有一个重复的 sqlite 数据库。我尝试删除重复项,但同时删除了两者。有没有办法生成新的数据库?数据并不是特别重要。
尽管我有最好的愿望,但我在一个似乎总是需要的领域遇到了麻烦。我的“word_search”文本字段总是要求输入数据,但我一直在努力确保选项允许空白。
我的模型是这个。您可以看到 blank=True,Null=True 选项
class IAV(models.Model):
z_score = models.DecimalField(max_digits = 4,decimal_places=4)
screens = models.IntegerField(default=0)
flu_proteins = models.IntegerField(default = 0)
Key_word = models.TextField(blank=True,null=True)
sess = models.ForeignKey(Sess_IAV,default=None)
Run Code Online (Sandbox Code Playgroud)
我的观点是这样的
def new_IAV(request):
if request.method == "POST":
form = IAVForm(request.POST,request.FILES)
if form.is_valid():
sess_ = Sess_IAV.objects.create()
form.save(
for_page=sess_,
z_score = form.cleaned_data("z_score"),
screens = form.cleaned_data("screens"),
flu_proteins = form.cleaned_data("flu_proteins"),
Key_word = form.cleaned_data("key_word"),
)
return redirect(sess_)
else:
print(form.errors)
else:
url=reverse('IAV_home')
return HttpResponseRedirect(url)
Run Code Online (Sandbox Code Playgroud)
我的表格是这样的。您可以看到 required=False 属性。
class IAVForm(forms.models.ModelForm):
z_score = forms.DecimalField(widget=forms.NumberInput(attrs={'class':'form-control','value':'0.0',}))
screens = forms.IntegerField(widget=forms.NumberInput(attrs={'class':'form-control','value':'0',}))
flu_proteins = forms.IntegerField(widget=forms.NumberInput(attrs={'class':'form-control','value':'0',}))
key_word = forms.CharField(widget=forms.Textarea(attrs={'class':'form-control','rows':1,'cols':10,'placeholder':'keword …Run Code Online (Sandbox Code Playgroud) 地狱我在安装libtorrent时遇到了非常艰难的时间,我不确定问题是什么.我在网上看到了很多类似的错误,但解决方案没有帮助,我很确定错误信息对于比较来说太模糊了.
当我跑./configure我得到
**
Building libtorrent-rasterbar 0.16.5
Checking for a C/C++ compiler to use:
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking how …Run Code Online (Sandbox Code Playgroud) 我在导入aws-sdk时遇到问题(或使用webpack进行构建)
我的代码是
var config = require('./config')
var AWS = require('aws-sdk');
AWS.config.region = config.region;
Run Code Online (Sandbox Code Playgroud)
这会导致以下构建错误:
./node_modules/aws-sdk/apis/cognito-identity-2014-06-30.min.json中的错误模块解析失败:解析'module.exports = {“ v。 。'您可能需要适当的加载程序来处理此文件类型。
多次。
如果我使用代码
var config = require('./config')
var AWS = require('aws-sdk/dist/aws-sdk');
AWS.config.region = config.region;
Run Code Online (Sandbox Code Playgroud)
我收到控制台错误
未捕获的TypeError:无法设置未定义的属性“ region”
我的webpack文件是:
module.exports = {
entry: 'entry.js',
// Place output files in `./dist/my-app.js`
output: {
path: __dirname + '/dist',
filename: 'my-app.js'
},
resolve: {.
extensions: [ '.js', '.json', '.jsx'].
},
module: {
rules: [
{
test: /\.json$/,
loader: 'json-loader'
}
]
}
};
Run Code Online (Sandbox Code Playgroud)
而我的package.json是:
{
"private": …Run Code Online (Sandbox Code Playgroud) 我已经尝试了我能想到的每个安装方法在我们的debian服务器上安装RPy2,无论如何我得到相同的消息.我已经在我的mac上成功安装并使用它.有什么我可能会失踪?
开始
Processing rpy2
Running setup.py -q bdist_egg --dist-dir /opt/rpy2/egg-dist-tmp-oft2ko
returned an empty string.
returned an empty string.
Configuration for R as a library:
include_dirs: ('/usr/share/R/include',)
libraries: ('R',)
library_dirs: ('/usr/lib64/R/lib',)
extra_link_args: ()
# OSX-specific (included in extra_link_args)
framework_dirs: ()
frameworks: ()
warning: no previously-included files matching '*patch*' found anywhere in distribution
warning: no previously-included files matching '*diff*' found anywhere in distribution
warning: no previously-included files matching '.hg' found anywhere in distribution
warning: no files found matching 'MANIFEST
Run Code Online (Sandbox Code Playgroud)
"
...
结束 …