我读了
http://www.packtpub.com/article/friends-via-email-social-web-application-django-1.0
并按照以下步骤操作:=>并更改我的setting.py
SITE_HOST = '127.0.0.1:8000'
DEFAULT_FROM_EMAIL = 'KSO Publisher <soeng@xxxx.com.kh>'
EMAIL_HOST = 'smtp.xxxx.com.kh'
EMAIL_PORT = '25'
EMAIL_HOST_USER = 'myusernamea@xxxx.com.kh'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_USE_TLS = False
Run Code Online (Sandbox Code Playgroud)
在我去命令行之后
python@python-desktop:~/workspace/kso$ python manage.py shell
Python 2.5.2 (r252:60911, Jul 22 2009, 15:35:03)
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from django.core.mail import send_mail
>>> emails = send_mail('Subject', 'Body of the message.','soeng@xxxx.com.kh',['pythonkhmer@gmail.com'])
Run Code Online (Sandbox Code Playgroud)
我收到了错误消息.
Traceback (most recent call last):
File "<console>", line 1, in <module>
File …
Run Code Online (Sandbox Code Playgroud) 我正在使用elementaryOS(基于ubuntu)
当我运行逗号行时:
kn3l@kn3l:/var/www/cronjob$
25 15 * * * /var/www/cronjob/helloworld.php > /var/www/cronjob/cron.log
Run Code Online (Sandbox Code Playgroud)
它适用于带终端命令行的crontab.
但当我使用PHP与我的代码(test.php)时:
-rwxrwxrwx 1 kn3l kn3l 47 Jun 6 14:59 test.php*
Run Code Online (Sandbox Code Playgroud)
test.php的
<?php
$output = shell_exec('crontab -l');
echo "<pre>$output</pre>";
Run Code Online (Sandbox Code Playgroud)
我去http://localhost/test.php
为什么我没有看到命令行的任何返回?
有人可以帮帮我吗?
当我在ubuntu上运行时
php artisan serve
Laravel开发服务器在http:// localhost:8000 /上启动
[Mon Apr 25 10:28:08 2016]无法收听localhost:8000(原因:无法分配请求的地址)
我的主机文件
/etc/hosts/
1 27.0.0.1 localhost
任何人过去常常面对同样的问题,我们怎么解决这个问题呢?
我有一个模特
class Employee_Type(models.Model):
def __unicode__(self):
return self.name
name = models.CharField(max_length=200, verbose_name="employee type")
class Employee(models.Model):
def __unicode__(self):
return self.name
name = models.CharField(max_length=200)
type = models.ForeignKey(Employee_Type)
address = models.CharField(max_length=500,blank=True, null=True)
telephone = models.CharField(max_length=100, blank=True, null=True)
fax = models.CharField(max_length=100, blank=True, null=True)
email = models.EmailField(max_length=200, blank=True, null=True)
active = models.BooleanField(default=True)
Run Code Online (Sandbox Code Playgroud)
我需要查询这样的事情:
employees = Employee.objects.filter(
Q(name__startswith=key_search) \
& Q(type__icontian= emp_type)#CAN I DO THIS?
Q(active=True)
)
Run Code Online (Sandbox Code Playgroud)
问题:对
Q(type__= emp_type) (type = models.ForeignKey(Employee_Type)) I cannot do this.
Run Code Online (Sandbox Code Playgroud)
这里有人请帮帮我?
我有两个数组:
$A = array('a','b','c','d')
$c = array('b','c','e','f')
Run Code Online (Sandbox Code Playgroud)
我想得到一个包含不在数组中的项的新数组$A
.所以它会是:
$result = array('e','f');
Run Code Online (Sandbox Code Playgroud)
因为'e'
而且'f'
不在$A
.
继承和OOP php中的一些属性除外?
我有一个A类
class A{
var a;
var b;
var c;
var d;
function todo1()
{
//more code here
}
function todo2()
{
//more code here
}
function todo_with_var_c()
{
//more code here
}
}
Run Code Online (Sandbox Code Playgroud)
$A_ = new A;
我希望得到一个新对象$B
,A
除了相同的对象var c
todo_with_var_c
所以我尝试了继承 php
class B extends A{
//TODO
}
$B_ = new $B;//$B_ will the same object $A_ but except `var c`
and and `todo_with_var_c`
Run Code Online (Sandbox Code Playgroud)
我该怎么做?谢谢!
我有一个数组数组
array(4) {
[0]=>
array(3) {
["a"]=>float(1000)
["b"]=>float(3)
["c"]=>float(500)
}
[1]=>
array(3) {
["a"]=>float(1000)
["b"]=>float(852)
["c"]=>float(500)
}
[2]=>
array(3) {
["a"]=>float(1000)
["b"]=>float(5)
["c"]=>float(500)
}
[3]=>
array(1) {
["e"]=>float(1000)
}
}
Run Code Online (Sandbox Code Playgroud)
结果将总和相同键的所有值,因此结果应为:
$result =
array(
"a" =>3000,
"b"=>900,
"c"=>1500,
"e"=>1000
)
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我解决这个问题.
谢谢.
我试图从单个数组进行分页
$input = Array
(
[0] => 'A',
[1] => 'B',
[2] => 'C'
...
)
Run Code Online (Sandbox Code Playgroud)
例 $show_per_page=2;
在第1页
paging($input,$page, $show_per_page);
$output = Array(
[0]=>'A',
[1]=>'B'
);
Run Code Online (Sandbox Code Playgroud)
在第2页
$output = Array(
[2]=>'B'
);
Run Code Online (Sandbox Code Playgroud)
我知道array_slice
但这不适合这种情况.任何人都知道如何做到这一点?
为什么我看到这个页面在错误的月份,它应该初始化显示August
而不是September
,我来自柬埔寨
我正在尝试使Firebase身份验证和Spring Boot适用于我的应用
这是我的Application.java
import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.reactive.function.client.WebClient;
import java.io.IOException;
@SpringBootApplication
@EnableScheduling
public class Application {
public static final Logger logger = LoggerFactory.getLogger("com.qmexpress");
static String FB_BASE_URL="https://qm-tracker-backend.firebaseio.com";
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
try {
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(new ClassPathResource("/qm-tracker-backend-firebase-adminsdk-wowh8-d8b0c278a7.json").getInputStream()))
.setDatabaseUrl(FB_BASE_URL)
.build();
FirebaseApp.initializeApp(options);
} catch (IOException e) {
e.printStackTrace();
}
}
@Bean
public WebClient webClient() {
return WebClient.create();
}
} …
Run Code Online (Sandbox Code Playgroud)